-- add_attrib_percent
-- create by zhuangsl
-- 技能: 百分比提高属性，不累积叠加

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 威力
        local attrib = para[1];
        local force = para[2];

        -- 提升的属性值，至少1点
        local value = math.modf(source.dbase:query(attrib, 0) * force / 1000);
        value = math.max(value, 1);

        -- 增加属性
        local propId = PropM.getPropId("attrib2");
        local prop = source.dbase:queryTemp("prop", "add_attrib_percent", {});
        if #prop > 0 then
            value = prop[1][3] + value;
        end
        prop = { propId, attrib, value, -1, };
        source.dbase:setTemp("prop", "add_attrib_percent", { prop, });

        -- 重整一次属性
        PropM.arrangeProps(source);

        -- TODO:增加命中动作
        SkillM.getSequence(source):hit(source, source, skillId);
        -- 抛出事件，刷新怪物属性
        EventMgr.fire(event.REFRESH_MONSTER_INFO);

        return value;
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { arr[1], tonumber(arr[2]), };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 威力
        local attrib = para[1];
        local force = para[2];

        local value = math.modf(source.dbase:query(attrib, 0) * force / 1000);

        desc = string.gsub(desc, "{value}", value);

        return desc;
    end,
}

